import { Injectable } from '@angular/core';
import { Events } from 'ionic-angular';

@Injectable()
export class DataService {

	dataMap: Map<string, any>
 
	constructor(
		public events: Events,

	) {
		this.dataMap = new Map<string, any>();
		console.log('Hello GlobalVars Provider');
	}

	/**
	 * 判断某变量名是否存在
	 * @param varName 
	 */
	varExist(varName: any): boolean {
		return (this.dataMap.has(varName));
	};

	/**
	 * 增加一个变量
	 * @param varName 
	 * @param value 
	 */
	setData(varName: string, value: any): void {
		this.dataMap.set(varName,value);
		 
	};

	/** 得到一个全局变量 **/
	getData(varName: string) {
		 return this.dataMap.get(varName);
	}

}